<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of soaUsers
 *
 * @author dxx
 */

namespace app\common\model\jsm;
use think\Model;

class Ibeacon extends Model {

    protected $table = 'jj_ibeacons';
    protected $connection = ['database' => 'jooj_jsm'];

    public function getIbeaconByCondition($condition,$field='*'){
        return $this->where($condition)->field($field)->find();
    }
    
    /**
     * 插入记录
     * @param type $data
     * @return type
     */
    public function insertIbeacon($data){
        
        $IbeaconData = [];
        $IbeaconData['mp_id'] = $data['mp_id'];
        $IbeaconData['name']  = $data['name'];    
        $IbeaconData['device_id'] = $data['device_id'];
        $IbeaconData['uuid'] = $data['uuid'];
        $IbeaconData['major']  = $data['major'];
        $IbeaconData['minor']  = $data['minor'];
        $IbeaconData['poi_id']  = $data['poi_id'];
        $IbeaconData['comment'] = $data['comment'];
        $IbeaconData['status']  = $data['status'];
        $IbeaconData['serial_number'] = $data['serial_number'];
        $IbeaconData['last_update_ts']  = $data['last_update_ts'];
        $IbeaconData['return_msg'] = $data['return_msg'];
        $IbeaconData['company_id']  = $data['company_id'];
        $IbeaconData['company_code'] = $data['company_code'];
        $IbeaconData['company_name'] = $data['company_name'];
        $IbeaconData['bind_store_id'] = $data['bind_store_id'];
        $IbeaconData['bind_store_name'] = $data['bind_store_name'];
        $IbeaconData['reffer_page_number'] = $data['reffer_page_number'];
        $IbeaconData['is_delete'] = $data['is_delete'];
        $IbeaconData['last_yaoyiyao_ts'] = $data['last_yaoyiyao_ts'];
        $IbeaconData['copy_storeid_ts']  = $data['copy_storeid_ts'];
        
        return $this->insertGetId($IbeaconData);
    }
}
